import cv2

cap = cv2.VideoCapture("/dev/video0")

while 1:
    f,img = cap.read()

    if not f:
        print("can't open camera")
        break
    cv2.imshow("img",img)
    cv2.waitKey(0)

cap.release()
cv2.destroyAllWindows()
